let mapleader = ","
nnoremap <leader>sv :source $MYVIMRC<cr>
inoremap jk <esc>

"编码
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
set encoding=prc
" 显示中文帮助
if version >= 603
    set helplang=cn
    set encoding=utf-8
endif
"语法高亮
syntax on
syntax enable

"显示行号
"set number

"自动缩进与C语言风格缩进
"set autoindent
"set cindent

"设置在vim中可以使用鼠标
"set mouse=a

"缩进宽度
set tabstop=4
"设置退格键时可以删除4个空格
set smarttab
set softtabstop=4
"设置自动对齐空格数
set shiftwidth=4
"将tab键自动转换为空格
set expandtab

"switch case 对齐风格
"set cino=g0,:0

"光标定位
set cursorline
set cursorcolumn

"配色
set t_Co=256
"colorscheme desert
colorscheme neodark
"molokai
"colorscheme molokai
"set background=dark

nnoremap <F1> :set nopaste<cr>
"F2 粘贴模式
nnoremap <F2> :set paste<cr>
au InsertLeave * set nopaste

"映射系统剪贴板操作
"复制到系统剪贴板
nnoremap <leader>y "+y<cr>
vnoremap <leader>y "+y
"从系统剪贴板粘贴到vim，并把光标移动到粘贴内容后
nnoremap <leader>p "+gp

"vim-easymotion
let g:EasyMotion_leader_key = 'f'

"vim-gitgutter
let g:gitgutter_max_signs = 10000 "show 10000 changes
"ms
set updatetime=1000

" taglist
let Tlist_Show_One_File=1 "只显示当前文件的tags
"let Tlist_WinWidth=40 "设置taglist宽度
let Tlist_Exit_OnlyWindow=1 "tagList窗口是最后一个窗口，则退出Vim
"let Tlist_Use_Right_Window=1 "在Vim窗口右侧显示taglist窗口
let Tlist_Ctags_Cmd="/usr/bin/ctags" "将taglist与ctags关联

"---------------------- lookupfile.vim  start ----------------------------
let g:LookupFile_MinPatLength = 3               "最少输入2个字符才开始查找
let g:LookupFile_PreserveLastPattern = 0        "不保存上次查找的字符串
let g:LookupFile_PreservePatternHistory = 1     "保存查找历史
let g:LookupFile_AlwaysAcceptFirst = 1          "回车打开第一个匹配项目
let g:LookupFile_AllowNewFiles = 0              "不允许创建不存在的文件
let g:LookupFile_SortMethod = ""                "关闭对搜索结果的字母排序
"if filereadable("/home/jason/cur/svt6dl/filenametags")
"设置tag文件的名字
"   let g:LookupFile_TagExpr ='"/home/jason/cur/svt6dl/filenametags"'
"endif

"根据不同的当前目录配置不同的g:LookupFile_TagExpr值
auto bufread /home/jason/cur/svt6dl/* so /home/jason/cur/svt6dl/.vimrc
auto bufread /home/jason/nda/svt3288/* so /home/jason/nda/svt3288/.vimrc
auto bufread /home/jason/svt3399/rk7.1/* so /home/jason/svt3399/rk7.1/.vimrc
auto bufread /home/jason/neoway/n1_APSDK_V009C/* so /home/jason/neoway/n1_APSDK_V009C/.vimrc
auto bufread /home/jason/boe3288/rk7.1/* so /home/jason/boe3288/rk7.1/.vimrc

"映射LookupFile为，lk
nmap <silent> <leader>lk :LUTags<cr>
"映射LUPath为，lp
nmap <silent> <leader>lp :LUPath<cr>
"映射LUBufs为，ll
nmap <silent> <leader>ll :LUBufs<cr>
"映射LUWalks为，lw
nmap <silent> <leader>lw :LUWalk<cr>
" lookup file with ignore case
function! LookupFile_IgnoreCaseFunc(pattern)
    let _tags = &tags
    try
        let &tags = eval(g:LookupFile_TagExpr)
        let newpattern = '\c' . a:pattern
        let tags = taglist(newpattern)
    catch
        echohl ErrorMsg | echo "Exception: " . v:exception | echohl NONE
        return ""
    finally
        let &tags = _tags
    endtry

    " Show the matches for what is typed so far.
    let files = map(tags, 'v:val["filename"]')
    return files
endfunction
let g:LookupFile_LookupFunc = 'LookupFile_IgnoreCaseFunc'

"---------------------- lookupfile.vim  end   ----------------------------

"The-NERD-Commenter 注释时加一个空格
" let NERDSpaceDelims = 1

"The-NERD-tree 树形目录打开
nmap <silent> <leader>n :NERDTreeToggle<cr>
"是否默认显示隐藏文件
let NERDTreeShowHidden=1

"Powerline
set laststatus=2 "vim有一个状态栏 加上powline则有两个状态栏
"set t_Co=256
let g:Powline_symbols='fancy'

"mru 映射回车,打开最近打开的文件
nmap <cr> :MRU<cr>

"undotree
nmap <silent> <leader>u :UndotreeToggle<cr>
if has("persistent_undo")
    set undodir=$HOME/.undodir "where to save undo histories"
    set undofile        "save undo's file closes"
    set undolevels=1000 "how many udos
    set undoreload=1000 "number of lines to save for undo"
endif

"minibufexpl
let g:miniBufExplMaxHeight=10
"minibufexpl插件这个设置保证在打开0个以上的文件是最高限制都是有用的
let g:miniBufExplorerMoreThanOne=1
"用<C-h,j,k,l>切换到上下左右的窗口
let g:miniBufExplMapWindowNavVim = 1
"用<C-箭头键>切换到上下左右窗口
let g:miniBufExplMapWindowNavArrows = 1
"let g:miniBufExplModSelTarget = 1
"let g:miniBufExplForceSyntaxEnable = 1

let g:NERDTree_title="[NERDTree]"
let g:winManagerWindowLayout='NERDTree|TagList'
function! NERDTree_Start()
  exec 'NERDTree'
endfunction
function! NERDTree_IsValid()
  return 1
endfunction
nmap wm :WMToggle<CR>

"vim-trailing-whitespace 去掉无用空格
map <leader><space> :FixWhitespace<cr>

"python-syntax
"let python_highlight_all = 1

""syntastic
"let g:syntastic_error_symbol = '✗'	"set error or warning signs
"let g:syntastic_warning_symbol = '⚠'
"let g:syntastic_check_on_open=1
"let g:syntastic_enable_highlighting = 0
""let g:syntastic_python_checker="flake8,pyflakes,pep8,pylint"
"let g:syntastic_python_checkers=['pyflakes']
""highlight SyntasticErrorSign guifg=white guibg=black
"let g:syntastic_cpp_include_dirs = ['/usr/include/']
"let g:syntastic_cpp_remove_include_errors = 1
"let g:syntastic_cpp_check_header = 1
"let g:syntastic_cpp_compiler = 'clang++'
"let g:syntastic_cpp_compiler_options = '-std=c++11 -stdlib=libstdc++'
"let g:syntastic_enable_balloons = 0	"whether to show balloons

" -----------------------------------------------------------------------------
" YouCompleteMe.vim
" 补全配置脚本
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'
" 跳转到定义处
nnoremap <leader>jd:YcmCompleter GoToDefinition<CR>
" 弹出列表时选择第1项的快捷键(默认为<TAB>和<Down>)
"let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
" 弹出列表时选择前1项的快捷键(默认为<S-TAB>和<UP>)
"let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
" 主动补全, 默认为<C-Space>
"let g:ycm_key_invoke_completion = '<C-x>'
" 停止显示补全列表(防止列表影响视野),可以按<C-x>重新弹出
"let g:ycm_key_list_stop_completion = ['<C-y>']
" 停止提示是否载入本地ycm_extra_conf文件
let g:ycm_confirm_extra_conf = 0
"let g:ycm_seed_identifiers_with_syntax = 1
" 开启YCM 基于标签引擎
let g:ycm_collect_identifiers_from_tags_files = 1
" 从第2个键入字符就开始罗列匹配项
let g:ycm_min_num_of_chars_for_completion = 2
" 开启输入注释时补全
let g:ycm_complete_in_comments = 1
" 开启输入字符串时补全
let g:ycm_complete_in_strings = 1
" 开启注释和字符串中收集补全
let g:ycm_collect_identifiers_from_comments_and_strings = 1
" 关闭函数预览
"let g:ycm_add_preview_to_completeopt = 0
" 关闭代码诊断
let g:ycm_show_diagnostics_ui = 0
" 设置标识符补全最小字符数
let g:ycm_min_num_identifier_candidate_chars = 2
" 设置以下语言自动弹出语义补全(默认需要输入'.->::'或者按主动补全组合键)
let g:ycm_semantic_triggers =  {
          \ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],
          \ 'cs,lua,javascript': ['re!\w{2}'],
          \ }

"LeaderF
let g:Lf_DefaultMode = 'NameOnly'
let g:Lf_WildIgnore = {
        \ 'dir': ['.svn','.git','.hg','out'],
        \ 'file': ['*.sw?','~$*','*.bak','*.exe','*.o','*.so','*.py[co]','*.png','*.jpg','*.class','*.zip','*.vim','*.apk','*.a','*.jar','*.ko']
        \}

"ctrlsf
let g:ctrlsf_ackprg = 'rg'

"vim-snippetsp
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"

"ale
nnoremap <F3> :ALEToggle<CR>
let g:ale_sign_column_always = 1
let g:ale_set_highlights = 1
let g:ale_sign_error = 'x'
let g:ale_sign_warning = '⚠'
"文件内容发生变化时不进行检查
let g:ale_lint_on_text_changed = 'never'
"打开文件时不进行检查
let g:ale_lint_on_enter = 0
"使用clang对c和c++进行语法检查，对python使用pylint进行语法检查,空则不检查
let g:ale_linters = {
    \   'c++': ['clang'],
    \   'c': ['clang'],
    \   'python': ['pylint'],
    \   'java': [],
    \}

" ----------------------------- Vundle Start -----------------------------
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'

Plugin 'Lokaltog/vim-easymotion'
Plugin 'airblade/vim-gitgutter'

Plugin 'taglist.vim'

"两个配色
Plugin 'KeitaNakamura/neodark.vim' "下载后，需要cp -rf ~/.vim/bundle/neodark/colors ~/.vim
Plugin 'tomasr/molokai' "下载后，需要cp -rf ~/.vim/bundle/molokai/colors ~/.vim
Plugin 'lookupfile'
Plugin 'genutils' "lookupfile 依赖
Plugin 'The-NERD-tree'
Plugin 'The-NERD-Commenter'
Plugin 'Lokaltog/vim-powerline'
Plugin 'mru.vim'
Plugin 'a.vim'
Plugin 'mbbill/undotree'
Plugin 'minibufexpl.vim'
Plugin 'vim-scripts/winmanager'

Plugin 'Valloric/YouCompleteMe'

Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-repeat'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'AutoClose'
Plugin 'Yggdroot/LeaderF'
Plugin 'bronson/vim-trailing-whitespace'
Plugin 'hdima/python-syntax'
"Plugin 'scrooloose/syntastic'
Plugin 'dyng/ctrlsf.vim'
Plugin 'vim-scripts/matchit.zip'
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'w0rp/ale'



call vundle#end()
filetype plugin indent on
" ----------------------------- Vundle End   -----------------------------
